package com.gitee.enums;


import com.gitee.exception.OrderException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum UploadTypeEnum {

    AVATAR(1, "/avatar/"),
    FOOD(2, "/food/")
    ;

    Integer code;

    String desc;

    public static String of(Integer code) {
        Objects.requireNonNull(code);
        return Stream.of(values()).filter(bean -> bean.code.equals(code)).findAny().map(UploadTypeEnum::getDesc)
                .orElseThrow(() -> new OrderException(ResponseEnum.PARAM_ERROR));

    }
}
